namespace ts2 {


    interface LabelledValue {
        label: string;
        size: number
    }
    function printLabel(LabelledObj: LabelledValue) {
        console.log(LabelledObj.label, LabelledObj.size);
    }
    let myObj = { size: 10, label: "Size 10 Object" };
    printLabel(myObj);

    interface Person {
        b?: string,
        a: string
    }
    const Person: Person = {
        a: "213"
    }

    interface Point {
        readonly x: number;
        readonly y: number;
    }
    let p1: Point = { x: 10, y: 200 };
    console.log(p1.x, p1.y)

    interface Person1 {
        b?: string,
        a: string,
        [propName: string]: any
    }
    const person: Person1 = {
        a: '2134',
        c: '3213'
    }

    interface SearchFunc {
        (source: string, subString: string): boolean;
    }

    let mySearch: SearchFunc;
    mySearch = function (source: string, sub: string): boolean {
        let result = source.search(sub);
        return result > -1;
    }

    interface StringArray {
        [index: number]: string;
    }
    let myArray: StringArray;
    myArray = ['Bob', 'Fred'];
    let myStr: string = myArray[0];

    interface ReadonlyStringArray {
        readonly [index: number]: string;
    }
    let myArray1: ReadonlyStringArray = [
        'Alice', 'Bob'
    ];

    interface A { name: string }
    interface A { age: number }
    var x1: A = { name: 'xx', age: 20 }

    interface B extends A {
        age: number
    }
    let obj: B = {
        age: 18,
        name: 'string'
    }

    interface Shape {
        color: string;
    }
    interface PenStroke {
        penWidth: number;
    }
    interface Square extends Shape, PenStroke {
        sideLength: number;
    }
    let square = <Square>{};
    square.color = 'blue';
    square.sideLength = 10;
    square.penWidth = 5.0;


    interface Counter {
        (start: number): string;
        interval: number;
        reset(): void;
    }
    function getCounter(): Counter {
        let counter = <Counter>function (start: number) { };
        counter.interval = 123;
        counter.reset = function () { };
        return counter;
    }
    let c = getCounter();
    c(10);
    c.reset();
    c.interval = 5.0;



    class Control {
        private state: any;
    }
    interface SelectableControl extends Control {
        select(): void;
    }
    class Button extends Control implements SelectableControl {
        select() { }
    }
    class TextBox extends Control { }
    class Image1 extends Control implements SelectableControl {
        select() { }
    }
    class Location1 { }
}

